package com.ruoyi.system.telMsg.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.telMsg.domain.TelSendMsg;
import com.ruoyi.system.telMsg.service.ITelSendMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 短信发送记录Controller
 *
 * @author ruoyi
 * @date 2025-03-15
 */
@RestController
@RequestMapping("/tel/msg")
public class TelSendMsgController extends BaseController {
    @Autowired
    private ITelSendMsgService telSendMsgService;

    /**
     * 查询短信发送记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TelSendMsg telSendMsg) {
        startPage();
        List<TelSendMsg> list = telSendMsgService.selectTelSendMsgList(telSendMsg);
        return getDataTable(list);
    }

    /**
     * 导出短信发送记录列表
     */
    @GetMapping("/export")
    public AjaxResult export(TelSendMsg telSendMsg) {
        List<TelSendMsg> list = telSendMsgService.selectTelSendMsgList(telSendMsg);
        ExcelUtil<TelSendMsg> util = new ExcelUtil<TelSendMsg>(TelSendMsg.class);
        return util.exportExcel(list, "短信发送记录数据");
    }

    /**
     * 获取短信发送记录详细信息
     */
//    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(telSendMsgService.selectTelSendMsgById(id));
    }

    /**
     * 新增短信发送记录
     */
//    @PostMapping
    public AjaxResult add(@RequestBody TelSendMsg telSendMsg) {
        return toAjax(telSendMsgService.insertTelSendMsg(telSendMsg));
    }

    /**
     * 修改短信发送记录
     */
//    @PutMapping
    public AjaxResult edit(@RequestBody TelSendMsg telSendMsg) {
        return toAjax(telSendMsgService.updateTelSendMsg(telSendMsg));
    }

    /**
     * 删除短信发送记录
     */
//	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(telSendMsgService.deleteTelSendMsgByIds(ids));
    }
}
